<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>超市订单管理系统</title>
    <link type="text/css" rel="stylesheet" href="../../static/css/style.css" th:href="@{/css/style.css}"/>
    <link type="text/css" rel="stylesheet" href="../../static/css/public.css" th:href="@{/css/public.css}"/>
    <link type="text/css" rel="stylesheet" href="../../static/css/pagination.css" th:href="@{/css/pagination.css}"/>
</head>
<body>

<!--头部-->
<div th:replace="commons/common::header"></div>
<!--时间-->
<div th:replace="commons/common::time"></div>
<!--主体内容-->
<section class="publicMian ">
    <!--left-->
    <div th:replace="commons/common::left"></div>
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>订单管理页面 >> 订单添加页面</span>
        </div>
        <div class="providerAdd">
            <form id="billForm" name="billForm">
                <!--div的class 为error是验证错误，ok是验证成功-->
                <!-- <input type="hidden" name="method" value="add"> -->
                <div>
                    <label for="billCode">订单编码：</label>
                    <input type="text" name="billCode" class="text" id="billCode" value="" required>
                    <!-- 放置提示信息 -->
                    <font color="red"></font>
                </div>
                <div>
                    <label for="productName">商品名称：</label>
                    <input type="text" name="productName" id="productName" value="" required>
                    <font color="red"></font>
                </div>
                <div>
                    <label for="productUnit">商品单位：</label>
                    <input type="text" name="productUnit" id="productUnit" value="" required>
                    <font color="red"></font>
                </div>
                <div>
                    <label for="productCount">商品数量：</label>
                    <input type="text" name="productCount" id="productCount" value="" required>
                    <font color="red"></font>
                </div>
                <div>
                    <label for="totalPrice">总金额：</label>
                    <input type="text" name="totalPrice" id="totalPrice" value="" required>
                    <font color="red"></font>
                </div>
                <div>
                    <label >供应商：</label>
                    <select name="providerId" id="providerId">
                        <option value="">请选择</option>
                        <option th:each="provider:${providerlist}" th:value="${provider.id}" th:text="${provider.proName}"></option>
                    </select>
                    <font color="red"></font>
                </div>
                <div>
                    <label >是否付款：</label>
                    <input type="radio" name="isPayment" value="1" checked="checked">未付款
                    <input type="radio" name="isPayment" value="2" >已付款
                </div>
                <div class="providerAddBtn">
                    <input type="button" name="add" id="addBtn" value="保存">
                    <input type="button" id="back" name="back" value="返回" >
                </div>
            </form>
        </div>
    </div>
</section>


<div th:replace="commons/common::footer"></div>
<script type="text/javascript" src="../../static/js/time.js" th:src="@{/js/time.js}"></script>
<script type="text/javascript" src="../../static/js/jquery-1.8.3.min.js" th:src="@{/js/jquery-1.8.3.min.js}"></script>
<script type="text/javascript" src="../../static/js/common.js" th:src="@{/js/common.js}"></script>
<script type="text/javascript" src="../../static/calendar/WdatePicker.js" th:src="@{/calendar/WdatePicker.js}"></script>
<script type="text/javascript" src="../../static/js/rollpage.js" th:src="@{/js/rollpage.js}"></script>
<script type="text/javascript" src="../../static/js/jquery.pagination.js" th:src="@{/js/jquery.pagination.js}"></script>
<script type="text/javascript" src="../../static/js/jquery.form.js" th:src="@{/js/jquery.form.js}"></script>
<script>
    $("#addBtn").click(function () {
        const billCode=$("#billCode").val();
        const productName=$("#productName").val();
        const productUnit=$("#productUnit").val();
        const productCount=$("#productCount").val();
        const totalPrice=$("#totalPrice").val();
        const providerId=$("#providerId").val();
        const isPayment=$("input[name='isPayment']").val();
        const jsonObj = {
            billCode: billCode,
            productName: productName,
            productUnit: productUnit,
            productCount: productCount,
            totalPrice: totalPrice,
            providerId: providerId,
            isPayment: isPayment
        };
        $.ajax({
            url:"[[@{/bill/doAdd}]]",
            type:"post",
            beforeSend:function () {
                return true;
            },
            data:jsonObj,
            success:function (result) {
                if (result.success){
                    window.location.href='[[@{/bill/list}]]';
                }
            }
        })
    })
</script>

</body>
</html>